<template>
  <div>
    <head-top head-title="日期列表" go-back='true'></head-top>
    <inline-calendar start-date="2012-04-28" :end-date="yesterday" v-model="value"  @on-change="onChange">  </inline-calendar>
      <group> 
      <!--<calendar title="其他可选日期" v-model="value" placeholder="若列表日期不能满足，可选择其他日期" @on-change="dateSechChange(value)"   :futureDayHide="yesterday"      disable-future></calendar>    -->    
     <!--<calendar title="其他可选日期" v-model="value" placeholder="若列表日期不能满足，可选择其他日期" @on-change="dateSechChange(value)"  :futureDayHide='1528782239'></calendar>  -->            
      <cell :title="i" v-for="i in day" :key="i" :link="{ path: '/net/dtarget',query: { date: i }}"></cell>    
      </group>     
      <transition name="router-slid" mode="out-in">
            <router-view></router-view>
    </transition>
  </div>
</template>
<script>
  import headTop from "src/components/head";
  import { Cell } from 'vux';
  import { Group } from 'vux';  
  import vue from "vue";
  import {  InlineCalendar, dateFormat } from 'vux';
  import { Calendar } from 'vux'

 // const today = dateFormat(new Date(), 'YYYY-MM-DD')
  export default{
    components:{
      headTop,Cell,Group,Calendar,InlineCalendar
    },
    data() {
      return {
      // day: [(new Date()).toLocaleDateString(),(new  Date().getTime()/1000)-60*60*24*1]
      value:'',
      currentValue:'',
      yesterday:'',
      day: []
    };
    },
    created(){//获取昨天之前30天的日期列表
      var date=new Date();
      for (var v=1;v<31;v++){
      var datev=new  Date().getTime();
      var dayv= (datev)-60*60*24*v*1000;
      var days=this.formatDate(new Date(dayv));
      this.day.push(days); 
    }
//默认取昨天的日期（日期选择器）
     this.yesterday = dateFormat(new Date().getTime() - 24 * 3600 * 1000, 'YYYY-MM-DD')
    // console.log("this.yesterday",this.yesterday);
    },
    methods: {
    
      onChange(val) {  
        console.log("val",val);
        this.$router.push({ path: "dtarget", query: {date:val}});    
      },



     formatDate(date){
        //var date = new Date();
        var seperator1 = "-";
        var year = date.getFullYear();
        var month = date.getMonth() + 1;
        var strDate = date.getDate();
        if (month >= 1 && month <= 9) {
          month = "0" + month;
        }
        if (strDate >= 0 && strDate <= 9) {
          strDate = "0" + strDate;
        }
         var currentdate = year + seperator1 + month + seperator1 + strDate;
        return currentdate;
      }

  }
};
</script>